﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mr="http://mishrareader.codeplex.com/Reader"
                    xmlns:settings="clr-namespace:MishraReader.ViewModels.Settings;assembly=MishraReader.ViewModels"
                    xmlns:mishraReader="clr-namespace:MishraReader;assembly=MishraReader.ViewModels">
    <DataTemplate DataType="{x:Type settings:ServiceAccountViewModel}" x:Key="notConfiguredServiceAccount">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Rectangle Fill="{DynamicResource MetroAccentBrush}" Grid.Row="1" />
            <TextBlock Text="{Binding ServicePackage.ServiceName, FallbackValue=[name]}" Margin="5,6,5,3" HorizontalAlignment="Center" Style="{DynamicResource MetroNormalText}" Foreground="{DynamicResource MetroHeadingColorLight}"/>
            <TextBlock Text="{x:Static mishraReader:Strings.ClickToConnect}" Grid.Row="1" Margin="5,3,5,6" HorizontalAlignment="Center" Style="{DynamicResource MetroNormalText}" Foreground="{DynamicResource MetroHeadingColorLight}" TextWrapping="Wrap"/>
        </Grid>
    </DataTemplate>
    <DataTemplate DataType="{x:Type settings:ServiceAccountViewModel}" x:Key="configuredServiceAccount">
        <Grid ToolTip="{Binding ServiceUserName}">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Rectangle Fill="{DynamicResource MetroAccentBrush}" Grid.RowSpan="2" />
            <TextBlock Text="{Binding ServicePackage.ServiceName}" Foreground="{DynamicResource MetroHeadingColorLight}" Style="{DynamicResource MetroNormalText}" Margin="5,6,5,3" HorizontalAlignment="Center"/>

            <TextBlock Grid.Row="1"
                x:Name="txtConnected" 
                Text="{x:Static mishraReader:Strings.ClickToDisconnect}" 
                Foreground="{DynamicResource MetroHeadingColorLight}" 
                Style="{DynamicResource MetroNormalText}"
                Margin="5,3,5,6"  
                HorizontalAlignment="Center"/>           
            
        </Grid>
        <DataTemplate.Triggers>
          
        </DataTemplate.Triggers>
    </DataTemplate>
    <DataTemplate DataType="{x:Type settings:ServiceAccountViewModel}" x:Key="serviceAccountSettings">
        <DataTemplate.Resources>
            <mr:ElementSpy x:Key="saVmSpy" />
        </DataTemplate.Resources>
        <Grid Margin="0,0,30,30">
            <Grid Width="150" Height="150" HorizontalAlignment="Left" VerticalAlignment="Top" >
                <Button x:Name="btnConfigure" Background="Transparent" Style="{StaticResource MetroImageButton}" Command="{Binding ConfigureCommand}" IsEnabled="{Binding IsSupported}">
                    <CheckBox IsHitTestVisible="False" Style="{StaticResource MetroImageCheckBox}" IsChecked="{Binding IsActivated}">
                        <Border Background="{StaticResource MetroTextLight}">
                            <Grid >
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="75" />
                                </Grid.RowDefinitions>
                                <Image Stretch="None" Source="{Binding ServiceLogo}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                <ContentPresenter x:Name="lowerTextContent"  Content="{Binding}" Grid.Row="1" />
                            </Grid>
                        </Border>
                    </CheckBox>
                </Button>
            </Grid>
            <ContentPresenter x:Name="configContent" Content="{Binding ConfigModel}" />            
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsConfigured}" Value="True">
                <Setter TargetName="lowerTextContent" Property="ContentTemplate" Value="{StaticResource configuredServiceAccount}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding IsConfigured}" Value="False">
                <Setter TargetName="lowerTextContent" Property="ContentTemplate" Value="{StaticResource notConfiguredServiceAccount}" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>